package com.ruoyi.web.controller.zdgl;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.DateUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.zdgl.domain.YwGsxxb;
import com.ruoyi.zdgl.service.IYwGsxxbService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import sun.plugin2.util.SystemUtil;

/**
 * 公司信息Controller
 * 
 * @author chrui
 * @date 2024-07-25
 */
@RestController
@RequestMapping("/zdgl/gsxxb")
public class YwGsxxbController extends BaseController
{
    @Autowired
    private IYwGsxxbService ywGsxxbService;
;

    /**
     * 查询公司信息列表
     */
    @PreAuthorize("@ss.hasPermi('zdgl:gsxxb:list')")
    @GetMapping("/list")
    public TableDataInfo list(YwGsxxb ywGsxxb)
    {
        startPage();
        List<YwGsxxb> list = ywGsxxbService.selectYwGsxxbList(ywGsxxb);
        return getDataTable(list);
    }

    /**
     * 导出公司信息列表
     */
    @PreAuthorize("@ss.hasPermi('zdgl:gsxxb:export')")
    @Log(title = "公司信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YwGsxxb ywGsxxb)
    {
        List<YwGsxxb> list = ywGsxxbService.selectYwGsxxbList(ywGsxxb);
        ExcelUtil<YwGsxxb> util = new ExcelUtil<YwGsxxb>(YwGsxxb.class);
        util.exportExcel(response, list, "公司信息数据");
    }

    /**
     * 获取公司信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('zdgl:gsxxb:query')")
    @GetMapping(value = "/{gsbh}")
    public AjaxResult getInfo(@PathVariable("gsbh") Long gsbh)
    {
        return success(ywGsxxbService.selectYwGsxxbByGsbh(gsbh));
    }

    /**
     * 新增公司信息
     */
    @PreAuthorize("@ss.hasPermi('zdgl:gsxxb:add')")
    @Log(title = "公司信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YwGsxxb ywGsxxb)
    {
        ywGsxxb.setCreateBy(getUsername());
        return toAjax(ywGsxxbService.insertYwGsxxb(ywGsxxb));
    }

    /**
     * 修改公司信息
     */
    @PreAuthorize("@ss.hasPermi('zdgl:gsxxb:edit')")
    @Log(title = "公司信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YwGsxxb ywGsxxb)
    {
        ywGsxxb.setUpdateBy(getUsername());
        return toAjax(ywGsxxbService.updateYwGsxxb(ywGsxxb));
    }

    /**
     * 删除公司信息
     */
    @PreAuthorize("@ss.hasPermi('zdgl:gsxxb:remove')")
    @Log(title = "公司信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{gsbhs}")
    public AjaxResult remove(@PathVariable Long[] gsbhs)
    {
        return toAjax(ywGsxxbService.deleteYwGsxxbByGsbhs(gsbhs));
    }
}
